import { Decorator_DtoIsNumber_Base } from '@/common/decorators/dtoIsNumber';
import { ApiProperty } from '@nestjs/swagger';
import { IsArray, IsNotEmpty, IsOptional, ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';

class DistributionRate_CreateUtilutil_Dto {
  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  @ApiProperty({ description: '规格Id' })
  id?: number;

  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  @ApiProperty({ description: '规格Id' })
  productId: number;

  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  @ApiProperty({ description: '用户id' })
  userClientId?: number;

  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  @ApiProperty({ description: '首单提成，10即代表10' })
  firstOrderRate: number;

  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  @ApiProperty({ description: '第二单提成，10即代表10' })
  secondOrderRate: number;
}

class DistributionRate_CreateUtil_Dto {
  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  @ApiProperty({ description: '平台Id' })
  platformId: number;

  @IsArray()
  @ValidateNested()
  @Type(() => DistributionRate_CreateUtilutil_Dto)
  products: DistributionRate_CreateUtilutil_Dto[];
}

export class DistributionRate_Create_Dto {
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => DistributionRate_CreateUtil_Dto)
  rates: DistributionRate_CreateUtil_Dto[];
}

export class DistributionRate_FindByUserClientId_Dto {
  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  @ApiProperty({ description: '用户id 不传用户id即查询普通推广者的提成比例' })
  userClientId?: number;
}
